home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / TEST / DEBUG_TO.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  4.3 KB  |  134 lines

  1.  
  2. package sub_arctic.test;
  3.  
  4. import sub_arctic.lib.*;
  5. import sub_arctic.input.*;
  6. import sub_arctic.output.drawable;
  7. import sub_arctic.constraints.std_function;
  8.  
  9. import java.awt.Font; // almost didn't need any AWT!
  10.  
  11. public class debug_top_test extends debug_interactor_applet 
  12. implements callback_object {
  13.  
  14.   public static final int angle_default=25;
  15.   public static final int length_default=20;
  16.   public static final String msg_length="Arrow Head Length: ";
  17.   public static final String msg_angle="Arrow Head Angle: ";
  18.   /* where we know how many arrowheads we need */
  19.   int arrowheads;
  20.   /* do something clever when we get a click */
  21.   public void callback(interactor from_obj, 
  22.                event      evt,
  23.                int        callback_num, 
  24.                Object     callback_info) {
  25.     int i;
  26.     line_display l;
  27.     /* is it a toggle?  */
  28.     if (from_obj instanceof toggle) {
  29.       lp.set_arrow_heads(((Integer)from_obj.user_info()).intValue());
  30.     } else {
  31.       /* its a slider */
  32.       /* loop over all children */
  33.       angle_label.set_text(msg_angle + angle_scale.value());
  34.       length_label.set_text(msg_length + length_scale.value());
  35.       for (i=0; i<lp.num_children();++i) {
  36.     l=(line_display)lp.child(i);
  37.     l.set_arrow_head_length(length_scale.value());
  38.     l.set_arrow_head_angle(angle_scale.value());
  39.       }
  40.     }
  41.       
  42.   }
  43.   /* this is where we hold the line_parent */
  44.   line_parent lp;
  45.   /* angle scale */
  46.   scale angle_scale;
  47.   scale length_scale;
  48.   label angle_label;
  49.   label length_label;
  50.   static String[] arrowhead_labels= {"No Arrow Heads", "One Arrow Head",
  51.                      "Two Arrow Heads"};
  52.   /*
  53.    * Set things up ... note: use start() not init()
  54.    */
  55.   public void build_ui(base_parent_interactor top) {
  56.     text_toggle_collection s1;
  57.     column c;
  58.  
  59.     // /* switch out the top */
  60.     // remove_top_interactor();
  61.     // debug_lens_top_level dtop = 
  62.     //  new debug_lens_top_level(top.x(), top.y(), top.w(), top.h());
  63.     // set_top_interactor(dtop);
  64.     // top = new fake_top_level(dtop);
  65.     //
  66.     // /* turn on debug */
  67.     // dtop.set_debugging(true);
  68.  
  69.       /* initialize arrow heads */
  70.     arrowheads=1;
  71.     /* width and height are bogus */
  72.     c=new column(0,0,10,10,10,3,true,true,true,column.CENTER_JUSTIFIED,
  73.          null);
  74.     s1=new text_toggle_collection(arrowhead_labels,true,150,this);
  75.     /* put the toggle for 1 arrow head on */
  76.     s1.nth_toggle(1).set_cur_state(1);
  77.     /* now build a slider and a label for angle*/
  78.     angle_label=new label(msg_angle + angle_default,
  79.               new Font("Helvetica",Font.BOLD, 16));
  80.     angle_scale=new scale(0,0,200,1,89,angle_default,10,this);
  81.     /* now build a scale and a label for length*/
  82.     length_label=new label(msg_length+ length_default,
  83.                new Font("Helvetica",Font.BOLD, 16));
  84.     length_scale=new scale(0,0,200,1,100,length_default,10,this);
  85.       
  86.       /* put all these interactors in the column */
  87.     c.add_child(s1);
  88.     c.add_child(angle_label);
  89.     c.add_child(angle_scale);
  90.     c.add_child(length_label);
  91.     c.add_child(length_scale);
  92.     /* make it fill */
  93.     c.set_h_constraint(std_function.offset(PARENT.Y2(),0));
  94.     top.add_child(c);
  95.     /* put the line parent in */
  96.     lp=new line_parent();
  97.     top.add_child(lp);
  98.     /* now build the constraints for lp... abut against the column */
  99.     lp.set_x_constraint(std_function.offset(PREV_SIBLING.X2(), 0));
  100.     lp.set_y_constraint(std_function.offset(PREV_SIBLING.Y(),0));
  101.     /* initialize lp to be right */
  102.     lp.set_arrow_head_length(angle_default);
  103.     lp.set_arrow_head_angle(length_default);
  104.     /* width and height fill */
  105.     lp.set_w_constraint(
  106.         std_function.fill(PREV_SIBLING.X2(), NEXT_SIBLING.X(), 0));
  107.     lp.set_h_constraint(std_function.offset(PARENT.Y2(), 0));
  108.   }
  109. }
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118. /*=========================== COPYRIGHT NOTICE ===========================
  119.  
  120. This file is part of the subArctic user interface toolkit.
  121.  
  122. Copyright (c) 1996 Scott Hudson and Ian Smith
  123. All rights reserved.
  124.  
  125. The subArctic system is freely available for most uses under the terms
  126. and conditions described in 
  127.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  128. and appearing in full in the lib/interactor.java source file.
  129.  
  130. The current release and additional information about this software can be 
  131. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  132.  
  133. ========================================================================*/
  134.